package com.example.i.spy;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class PlayerNameScreen extends Activity {
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        setContentView(R.layout.activity_player_name_screen);
        
        // when they press continue, start the game.
        Button continueButton = (Button)findViewById(R.id.playerNameContinue);
        continueButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) 
			{
				// get each player's name and attach them to the intent, so the main activity can display them
				String player1Name;
		    	String player2Name;
		        EditText player1TextField = (EditText)findViewById(R.id.player1EditName);
		        EditText player2TextField = (EditText)findViewById(R.id.player2EditName);
		        player1Name = player1TextField.getText().toString();
		        player2Name = player2TextField.getText().toString();
				Intent continueIntent = new Intent(PlayerNameScreen.this, MainActivity.class);
				continueIntent.putExtra("playerName1", player1Name);
				continueIntent.putExtra("playerName2", player2Name);
				startActivity(continueIntent);
				
			}
		});
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_player_name_screen, menu);
        return true;
    }
}
